﻿using System;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void YGRYLGB02(DataSet db)
        {
            try
            {
                DataTable tbGLLG = db.Tables["GLLG"];  
                DataTable dtOutput = new DataTable();
                int idx = 1;
                //GPSPPART,YSP,GPGART,GPGVAR,GPGFARBE,GPFBPART,PO,GPBEM2,GLLO,GLLB,GLLP ,GPNEUDAT, GPLIEFSCH,GLBSTSP,GLBSTKG,PRICE 
                #region======Title===========
                exAgent.SetCellValue(2, idx++, "批号"); dtOutput.Columns.Add("GPSPPART", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "批号(备注)"); dtOutput.Columns.Add("YSP", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "品种"); dtOutput.Columns.Add("GPGART", typeof(System.String));
                exAgent.SetCellValue(2, idx++, ""); dtOutput.Columns.Add("GPGVAR", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "色号"); dtOutput.Columns.Add("GPGFARBE", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "品名"); dtOutput.Columns.Add("GSHANDLNR", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "缸号"); dtOutput.Columns.Add("GPFBPART", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "产地"); dtOutput.Columns.Add("PO", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "供应商"); dtOutput.Columns.Add("GPBEM2", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "库"); dtOutput.Columns.Add("GLLO", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "库区"); dtOutput.Columns.Add("GLLB", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "库位"); dtOutput.Columns.Add("GLLP", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "入库日期"); dtOutput.Columns.Add("GPNEUDAT", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "等级"); dtOutput.Columns.Add("GPLIEFSCH", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "包数"); dtOutput.Columns.Add("GLBSTSP", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "数量"); dtOutput.Columns.Add("GLBSTKG", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "单价"); dtOutput.Columns.Add("PRICE", typeof(System.String)); 
                #endregion 
                dtOutput.Merge(tbGLLG, false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                    row["GPSPPART"] = GetGB2312Value(row["GPSPPART"].ToString());
                    row["YSP"] = GetGB2312Value(row["YSP"].ToString());
                    row["GPGFARBE"] = GetGB2312Value(row["GPGFARBE"].ToString());
                    row["GSHANDLNR"] = GetGB2312Value(row["GSHANDLNR"].ToString());
                    row["GPFBPART"] = GetGB2312Value(row["GPFBPART"].ToString());
                    row["PO"] = GetGB2312Value(row["PO"].ToString());
                    row["GPBEM2"] = GetGB2312Value(row["GPBEM2"].ToString());
                    row["PRICE"] = GetGB2312Value(row["PRICE"].ToString());
                }
                exAgent.DataTableToExcel(dtOutput, 4, 1);
                int countx = dtOutput.Rows.Count;
                exAgent.SetCellValue(1, 1, 1);
                exAgent.BatchConvert2Number(4, 15, countx + 3, 16);
                exAgent.SetCellValue(1, 1, "原料库存");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
         
    }
}